#pragma once
#include "ICommand.h"
#include "Fatworm.h"

class MoveCommand : public ICommand {
private:
	Fatworm* host;
	TPoint target;
public:
	MoveCommand(Fatworm& x, TPoint y) {
		host = &x;
		target = y;
		type = "move";
	}
	virtual void execute(void) {
		Fatworm& ship = *host;
		ship.moveToPoint(target);
	}
};

class RotateCommand : public ICommand {
private:
	Fatworm* host;
	float r;
public:
	RotateCommand(Fatworm& x, float y) {
		host = &x;
		r = y;
		type = "rotate";
	}
	virtual void execute(void) {
		Fatworm& ship = *host;
		ship.setRotation(r);
	}
};

class RotateMoveCommand : public ICommand {
private:
	Fatworm* host;
	float r;
	float dist;
public:
	RotateMoveCommand(Fatworm& x, float y, float z) {
		host = &x;
		r = y;
		dist = z;
		type = "rotate_move";
	}

	virtual void execute(void) {
		Fatworm& ship = *host;
		ship.moveToPoint(ship.pos.rotate(r).normizeTo(dist));
	}
};

class StopCommand : public ICommand {
private:
	Fatworm* host;
public:
	StopCommand(Fatworm& x) {
		host = &x;
		type = "stop";
	}

	virtual void execute(void) {
		Fatworm& ship = *host;
		ship.stopMov = true;
	}
};